#include <iostream>
#include <chrono>
#include <cmath>

#include "RenderWindow.h"

void render(float angle) {
    glBegin(GL_TRIANGLES);
    glVertex2f(cos(angle) * 0.5f, sin(angle) * 0.5f);
    glVertex2f(0.0f, 0.5f);
    glVertex2f(cos(angle + 2*M_PI/3) * 0.5f, sin(angle + 2*M_PI/3) * 0.5f);
    glEnd();
}

int main(int argc, char* argv[])
{
    auto win = Window::Create();
    win->SetWidth(640);
    win->SetHeight(480);
    win->Init();

    win->MakeCurrent();
    float startTime = glfwGetTime();
    while(win->IsOpen())
    {
        glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT);

        render(glfwGetTime() - startTime);
        win->SwapBuffers();
    }

    win->UnMakeCurrent();
    win->Destroy();

    return 0;
}